package com.example.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 爬虫配置类
 * 职责：管理爬虫的所有配置参数
 * 配置项：
 * - seedUrl: 爬虫起始URL
 * - maxDepth: 最大爬取深度
 * - maxCount: 最大爬取数量
 * - requestDelay: 请求延迟时间(ms)
 * - savePath: 数据保存路径
 */
@Configuration
@ConfigurationProperties(prefix = "crawler")
public class CrawlerConfig {
    // 基础配置
    private String seedUrl;
    private int maxDepth;
    private long maxCount;
    private String savePath;
    
    // 请求配置
    private RequestConfig request = new RequestConfig();
    
    public static class RequestConfig {
        private boolean delayEnabled = true;
        private int delayMin = 3000;
        private int delayMax = 10000;
        private int maxPerHour = 100;
        private int maxPerDay = 1000;
        private int maxFailures = 3;
        private int retryDelay = 300000;

        // Getters and Setters
        public boolean isDelayEnabled() {
            return delayEnabled;
        }

        public void setDelayEnabled(boolean delayEnabled) {
            this.delayEnabled = delayEnabled;
        }

        public int getDelayMin() {
            return delayMin;
        }

        public void setDelayMin(int delayMin) {
            this.delayMin = delayMin;
        }

        public int getDelayMax() {
            return delayMax;
        }

        public void setDelayMax(int delayMax) {
            this.delayMax = delayMax;
        }

        public int getMaxPerHour() {
            return maxPerHour;
        }

        public void setMaxPerHour(int maxPerHour) {
            this.maxPerHour = maxPerHour;
        }

        public int getMaxPerDay() {
            return maxPerDay;
        }

        public void setMaxPerDay(int maxPerDay) {
            this.maxPerDay = maxPerDay;
        }

        public int getMaxFailures() {
            return maxFailures;
        }

        public void setMaxFailures(int maxFailures) {
            this.maxFailures = maxFailures;
        }

        public int getRetryDelay() {
            return retryDelay;
        }

        public void setRetryDelay(int retryDelay) {
            this.retryDelay = retryDelay;
        }
    }

    // Getters and Setters
    public String getSeedUrl() {
        return seedUrl;
    }

    public void setSeedUrl(String seedUrl) {
        this.seedUrl = seedUrl;
    }

    public int getMaxDepth() {
        return maxDepth;
    }

    public void setMaxDepth(int maxDepth) {
        this.maxDepth = maxDepth;
    }

    public long getMaxCount() {
        return maxCount;
    }

    public void setMaxCount(long maxCount) {
        this.maxCount = maxCount;
    }

    public String getSavePath() {
        return savePath;
    }

    public void setSavePath(String savePath) {
        this.savePath = savePath;
    }

    public RequestConfig getRequest() {
        return request;
    }

    public void setRequest(RequestConfig request) {
        this.request = request;
    }
} 